Skip to main content
Version: 3.0.0

Sample Code

The XREAL SDK includes numerous sample scenes and code examples to help you understand and implement AR features in your applications. These samples demonstrate the capabilities of the SDK and provide reference implementations for various functionalities.

Sample Code Organization​

In the XREAL SDK plugin, sample code is provided in two forms:

  • Demo Unity scenes that you can run directly
  • C# script implementations that you can reference in your own code

The samples are organized into several categories in the plugin structure:

Interaction Basics​

Examples for input handling and interaction with virtual objects.

FeatureUnity SceneSample Code
Controller BasicsHelloMRHelloMR
Display Stability OptimizationFocusPlaneFocusPlanePanel
Render MetricsMetricsMetricsPanel
RayLaserXREALLaserXREALLaserReticle
XREALLaserVisual
StereoVideoStereoVideoStereoVideoDemo

AR Features​

Examples demonstrating core AR capabilities such as tracking, detection, and meshing.

FeatureUnity SceneSample Code
Image TrackingBasicImageTrackingTrackedImageInfoManager
Plane DetectionPlaneDetectionARFeatheredPlaneMeshVisualizer
Mesh ClassificationMeshClassificationMeshClassificationFracking
Basic MeshingNormalMeshMeshSaver
MeshSaveUtility
MeshBlockInfo
MeshChangeStateInfo
Spatial AnchorAnchorsAnchors.5(For ARF 5.0)
Anchors.6(For ARF 6.0)
AnchorInfo
ConfirmDialog
MapQualityBar
MapQualityIndicator
RGBCameraRGBCameraARFoundationCameraSample

Camera Features​

Examples for accessing and utilizing the RGB camera.

FeatureUnity SceneSample Code
Video Recording & Photo CaptureRGBCameraAndCaptureCaptureExample
Accessing RGB Camera DataRGBCameraAndCaptureRGBCameraExample
First Person ViewFirstPersonViewStreamingCastFirstPersonStreammingCast

Other Examples​

Additional demos and experimental features.

FeatureUnity SceneSample Code
XREAL MarkerMarkerTrackingMarkerImageExampleController

Accessing the Sample Code​

To access these sample projects in your Unity environment:

  1. Open your Unity project

  2. Go to Window > Package Manager

  3. Find and select XREAL XR Plugin from the package list

  4. Navigate to the Samples tab

  5. Click the Import button next to any sample you want to use in your project

image-20250305165653216

You can import individual samples based on the specific feature you want to implement, or import all samples to explore the full range of XREAL SDK capabilities.

Using the Sample Code​

To use these samples:

  • Open the XREAL SDK in Unity
  • Navigate to the relevant scene in the project panel
  • Run the scene to see the feature in action
  • Review the attached scripts to understand the implementation Each sample demonstrates a specific feature or capability of the XREAL SDK and can serve as a starting point for implementing similar functionality in your own applications. For detailed information on specific features, refer to the corresponding documentation sections linked in the table above.